<?php

class KolaPresenter extends BasePresenter
{

	public function renderDefault()
	{
	}
	public function renderList($id)
	{
		$kola = new ZapasKoloModel();
		$soutez = new SoutezModel();
		$zapas = new ZapasModel();
		$tym = new TymModel();
		$this->template->soutez_nazev = $soutez->findById($id)->fetch();
		
		
		$tmp_kola = $kola->findBySoutezId($id)->fetchAll();
		$tymy = $tym->findAll()->fetchPairs('id','nazev');
		
		foreach($tmp_kola as $item){
			$tmp_zapas = $zapas->findByZapasKolaId($item->id)->fetchAll();
			$item['zapasy'] = $tmp_zapas;
			foreach($item['zapasy'] as $item2){
				$tym_soutez = $soutez->tym_soutez_findById($item2['tym_soutez_id_a'])->fetch();
				$tmp_tyma = $tym->findById($tym_soutez['tym_id'])->fetch();
				
				$item2['tyma_nazev'] = $tmp_tyma['nazev'];
				$tym_soutez = $soutez->tym_soutez_findById($item2['tym_soutez_id_b'])->fetch();
				$tmp_tymb = $tym->findById($tym_soutez['tym_id'])->fetch();
				
				$item2['tymb_nazev'] = $tmp_tymb['nazev'];
			}
		}
		$this->template->kola = $tmp_kola;
		
	}

	
}
